/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmConsPagar.java
 *
 * Created on 22/09/2009, 09:41:47
 */
package associados.telas;

import associados.bd.AssociadoDAO;
import associados.classes.Associado;
import banco.classes.Banco;
import conexao.DAOException;
import endereco.classes.Endereco;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import orgaoEmissor.classes.OrgaoEmissor;
import utilitarios.sigap;

public class FrmCadastroAssociado extends javax.swing.JFrame {

    /** Creates new form FrmConsPagar */
    public FrmCadastroAssociado(Associado associado) {
        this.associado = associado;
        try {
            dao = new AssociadoDAO();

        } catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, ex.getMessage());


        }

       

        initComponents();
         if(this.associado.getIdAssociado()>0){
           populaTela();

        }
        URL url = this.getClass().getResource("/imagens/logo_mini.png");
        Image imagemTitulo = Toolkit.getDefaultToolkit().getImage(url);
        this.setIconImage(imagemTitulo);
        this.setLocationRelativeTo(null);
        setVisible(true);


    }

    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jDialog1 = new javax.swing.JDialog();
        jPopupMenu1 = new javax.swing.JPopupMenu();
        jPopupMenu2 = new javax.swing.JPopupMenu();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        AssociadosjPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        SexojPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        nomejTextField1 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        CEPjFormattedTextField1 = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        tipologradourojComboBox1 = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        logradourojTextField2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        numjTextField3 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        bairrojTextField2 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tipojComboBox1 = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        cidadejTextField2 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        emailjTextField2 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        situacaojComboBox2 = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        complementojTextField2 = new javax.swing.JTextField();
        jToolBar1 = new javax.swing.JToolBar();
        jButton4 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        recadoljFormattedTextField1 = new javax.swing.JFormattedTextField();
        CelularjLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        nomeMaejTextField2 = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        nCPFjFormattedTextField1 = new javax.swing.JFormattedTextField();
        jLabel19 = new javax.swing.JLabel();
        nRGjTextField2 = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        dtNascjFormattedTextField1 = new javax.swing.JFormattedTextField();
        jLabel22 = new javax.swing.JLabel();
        numBeneficiojTextField2 = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        vlBeneficiojFormattedTextField1 = new javax.swing.JFormattedTextField();
        jLabel24 = new javax.swing.JLabel();
        percentualjFormattedTextField1 = new javax.swing.JFormattedTextField();
        jLabel25 = new javax.swing.JLabel();
        mesCompetenciajFormattedTextField1 = new javax.swing.JFormattedTextField();
        jLabel26 = new javax.swing.JLabel();
        nomeResponsaveljTextField2 = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        numAgenciajTextField2 = new javax.swing.JTextField();
        jLabel28 = new javax.swing.JLabel();
        nomeAgentePagadorjTextField2 = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        femininojRadioButton1 = new javax.swing.JRadioButton();
        masculinojRadioButton2 = new javax.swing.JRadioButton();
        residencialjFormattedTextField3 = new javax.swing.JFormattedTextField();
        celularljFormattedTextField4 = new javax.swing.JFormattedTextField();
        estadojComboBox3 = new javax.swing.JComboBox();
        orgaoEmissorjFormattedTextField2 = new javax.swing.JFormattedTextField();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        IncluirjButton = new javax.swing.JButton();
        LimparjButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cadastro de Associado");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        AssociadosjPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        AssociadosjPanel.setPreferredSize(new java.awt.Dimension(800, 600));
        AssociadosjPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/tick.png"))); // NOI18N
        jButton1.setText("Salvar");
        jButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SalvarCadastroAssociado(evt);
            }
        });
        jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 10, -1, -1));

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cross.png"))); // NOI18N
        jButton2.setText("Fechar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FecharCadastro(evt);
            }
        });
        jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 10, -1, -1));

        AssociadosjPanel.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 360, 470, 40));

        SexojPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Foto");
        jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        SexojPanel2.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, 80, 110));

        nomejTextField1.setFont(new java.awt.Font("Tahoma", 0, 12));
        SexojPanel2.add(nomejTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 30, 340, -1));

        jButton3.setText("Adicionar");
        SexojPanel2.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 150, -1, -1));

        jLabel3.setText("CEP");
        SexojPanel2.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 66, -1, -1));

        try {
            CEPjFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##### - ###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        SexojPanel2.add(CEPjFormattedTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 80, 70, -1));

        jLabel4.setText("Tipo Logradouro");
        SexojPanel2.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 66, -1, -1));

        tipologradourojComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Alameda", "Avenida", "Beco$", "Estrada", "Jardim", "Largo", "Loteamento", "Parque", "Praça", "Praia", "Rodovia", "Rua", "Servidão", "Travessa", "Trevo", "Via", "Vila" }));
        SexojPanel2.add(tipologradourojComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 80, 80, -1));

        jLabel5.setText("Logradouro");
        SexojPanel2.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 66, -1, -1));
        SexojPanel2.add(logradourojTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 80, 340, -1));

        jLabel6.setText("Número");
        SexojPanel2.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 66, -1, -1));
        SexojPanel2.add(numjTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 80, 50, -1));

        jLabel7.setText("Bairro");
        SexojPanel2.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 106, -1, -1));
        SexojPanel2.add(bairrojTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 120, 170, -1));

        jLabel8.setText("Tipo Associado");
        SexojPanel2.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 16, -1, -1));

        tipojComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "INSS", "Outros" }));
        SexojPanel2.add(tipojComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 30, -1, -1));

        jLabel9.setText("Cidade");
        SexojPanel2.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 106, -1, -1));
        SexojPanel2.add(cidadejTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 120, 170, -1));

        jLabel10.setText("Estado");
        SexojPanel2.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 106, -1, -1));

        jLabel11.setText("E-mail");
        SexojPanel2.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 144, -1, -1));
        SexojPanel2.add(emailjTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 161, 290, -1));

        jLabel12.setText("Situação");
        SexojPanel2.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 16, -1, -1));

        situacaojComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ativo", "Inativo" }));
        SexojPanel2.add(situacaojComboBox2, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 30, -1, -1));

        jLabel13.setText("Complemento");
        SexojPanel2.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 106, -1, -1));
        SexojPanel2.add(complementojTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 120, 160, -1));

        jToolBar1.setRollover(true);
        SexojPanel2.add(jToolBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/magnifier.png"))); // NOI18N
        SexojPanel2.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 80, 20, 20));

        jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/telephone.png"))); // NOI18N
        jLabel14.setText("Residencial");
        SexojPanel2.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 144, -1, -1));

        try {
            recadoljFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        SexojPanel2.add(recadoljFormattedTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 161, 90, -1));

        CelularjLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/phone.png"))); // NOI18N
        CelularjLabel15.setText("Celular");
        SexojPanel2.add(CelularjLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 144, -1, -1));

        jLabel16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/telephone.png"))); // NOI18N
        jLabel16.setText("Recado");
        SexojPanel2.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 144, -1, -1));

        jLabel17.setText("Nome Mãe");
        SexojPanel2.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 190, -1, -1));
        SexojPanel2.add(nomeMaejTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 204, 200, -1));

        jLabel18.setText("Número do CPF");
        SexojPanel2.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 190, -1, -1));

        try {
            nCPFjFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        nCPFjFormattedTextField1.setText("000.070.499-78");
        nCPFjFormattedTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                validarCPF(evt);
            }
        });
        SexojPanel2.add(nCPFjFormattedTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 204, 90, -1));

        jLabel19.setText("Número do RG");
        SexojPanel2.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 190, -1, -1));
        SexojPanel2.add(nRGjTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 204, 100, -1));

        jLabel20.setText("Orgão Emissor");
        SexojPanel2.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 190, -1, -1));

        jLabel21.setText("Data Nasc");
        SexojPanel2.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 190, -1, -1));

        dtNascjFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("##/##/####"))));
        SexojPanel2.add(dtNascjFormattedTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 204, 70, -1));

        jLabel22.setText("Nº Beneficio");
        SexojPanel2.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 230, -1, -1));
        SexojPanel2.add(numBeneficiojTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 244, 100, -1));

        jLabel23.setText("Valor Benefício");
        SexojPanel2.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 230, -1, -1));

        vlBeneficiojFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        SexojPanel2.add(vlBeneficiojFormattedTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 244, 100, -1));

        jLabel24.setText("% Desc");
        SexojPanel2.add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 230, -1, -1));

        percentualjFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        SexojPanel2.add(percentualjFormattedTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 244, 60, -1));

        jLabel25.setText("Mês / Ano Inicio Pagto");
        SexojPanel2.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 270, -1, -1));

        try {
            mesCompetenciajFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("## / ####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        SexojPanel2.add(mesCompetenciajFormattedTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 284, 120, -1));

        jLabel26.setText("Responsável Benefício");
        SexojPanel2.add(jLabel26, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 230, -1, -1));
        SexojPanel2.add(nomeResponsaveljTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 244, 300, -1));

        jLabel27.setText("Nº Agência");
        SexojPanel2.add(jLabel27, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 270, -1, -1));
        SexojPanel2.add(numAgenciajTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 284, 100, -1));

        jLabel28.setText("Nome do Agente Pagador");
        SexojPanel2.add(jLabel28, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 270, -1, -1));
        SexojPanel2.add(nomeAgentePagadorjTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 284, 320, -1));

        jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        femininojRadioButton1.setText("Feminino");
        jPanel4.add(femininojRadioButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(7, 3, -1, 20));

        masculinojRadioButton2.setText("Masculino");
        jPanel4.add(masculinojRadioButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(7, 23, -1, 20));

        SexojPanel2.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 10, 90, 50));

        try {
            residencialjFormattedTextField3.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        SexojPanel2.add(residencialjFormattedTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 161, 90, -1));

        try {
            celularljFormattedTextField4.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        SexojPanel2.add(celularljFormattedTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 161, 90, -1));

        estadojComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SC", "RS", "PR", "SP", "RJ", "ES", "MG", "MT", "MS", "BH" }));
        SexojPanel2.add(estadojComboBox3, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 120, 60, -1));

        try {
            orgaoEmissorjFormattedTextField2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        SexojPanel2.add(orgaoEmissorjFormattedTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 204, 70, -1));

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/magnifier.png"))); // NOI18N
        SexojPanel2.add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 284, 20, 20));

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/magnifier.png"))); // NOI18N
        SexojPanel2.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 204, 20, 20));

        jLabel2.setText("Nome");
        SexojPanel2.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 16, -1, -1));

        jTabbedPane1.addTab("Dados do Associado", SexojPanel2);

        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Data", "Descrição"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(30);
        jTable1.getColumnModel().getColumn(1).setPreferredWidth(500);

        jPanel3.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 720, 290));

        IncluirjButton.setText("Incluir");
        jPanel3.add(IncluirjButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 330, -1, -1));

        LimparjButton.setText("Limpar");
        jPanel3.add(LimparjButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 330, -1, -1));

        jTabbedPane1.addTab("Histórico", jPanel3);

        AssociadosjPanel.add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 760, 350));

        getContentPane().add(AssociadosjPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 770, 410));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SalvarCadastroAssociado(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SalvarCadastroAssociado

        associado.setNome(nomejTextField1.getText());
        associado.setSituacao((String) situacaojComboBox2.getSelectedItem());
        associado.setTipoAssociado((String) tipojComboBox1.getSelectedItem());
        if (masculinojRadioButton2.isSelected()) {
            associado.setSexo("M");
        } else {
            associado.setSexo("F");
        }
        associado.setDataNasc((Date) dtNascjFormattedTextField1.getValue());
        associado.setNumBeneficio(numBeneficiojTextField2.getText());
        associado.setCpf(nCPFjFormattedTextField1.getText());
        associado.setRg(nRGjTextField2.getText());
        associado.setNomeMae(nomeMaejTextField2.getText());
        associado.setNumero(numjTextField3.getText());
        associado.setComplemento(complementojTextField2.getText());
        associado.setFoneResidencial(residencialjFormattedTextField3.getText());
        System.out.println(residencialjFormattedTextField3.getText());
        associado.setFoneCelular(celularljFormattedTextField4.getText());
        associado.setFoneRecado(recadoljFormattedTextField1.getText());
        System.out.println(celularljFormattedTextField4.getText());
        associado.setEmail(emailjTextField2.getText());
        float d = ((Number) vlBeneficiojFormattedTextField1.getValue()).floatValue();
        associado.setValor(d);
        associado.setAgentePagador(nomeAgentePagadorjTextField2.getText());
        associado.setPercDesconto(Double.parseDouble(percentualjFormattedTextField1.getText()));
        associado.setMesCompetencia(mesCompetenciajFormattedTextField1.getText());
        associado.setResponsavel(nomeResponsaveljTextField2.getText());
        Endereco end = new Endereco();
        end.setBairro(bairrojTextField2.getText());
        end.setCep(CEPjFormattedTextField1.getText());
        end.setCidade(cidadejTextField2.getText());
        end.setEstado((String) estadojComboBox3.getSelectedItem());
        Banco banco = new Banco();
        banco.setNome(nomeAgentePagadorjTextField2.getText());
        OrgaoEmissor emissor = new OrgaoEmissor();
        emissor.setNome(orgaoEmissorjFormattedTextField2.getText());



        try {
            dao.salvar(associado);
            JOptionPane.showMessageDialog(this, "Dados salvos com sucesso");
        } catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(this, "Dados não foram salvos");
        }
    }//GEN-LAST:event_SalvarCadastroAssociado

    private void FecharCadastro(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FecharCadastro
        this.dispose();
    }//GEN-LAST:event_FecharCadastro

    private void validarCPF(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_validarCPF
        sigap valida = new sigap();
        if (!valida.validaCPF(nCPFjFormattedTextField1.getText())) {
            JOptionPane.showMessageDialog(null, "CPF Inválido");
        }
    }//GEN-LAST:event_validarCPF

    /**
     * @param args the command line arguments
     */
   
  

    //populando a tela de edição
    private void populaTela() {
        nomejTextField1.setText(associado.getNome());
        situacaojComboBox2.setSelectedItem(associado.getSituacao());
        tipojComboBox1.setSelectedItem(associado.getTipoAssociado());
        if (masculinojRadioButton2.isSelected()) {
            associado.setSexo("M");
        } else {
            associado.setSexo("F");
        }
        complementojTextField2.setText(associado.getComplemento());
        numjTextField3.setText(associado.getNumero());
      //  CEPjFormattedTextField1.setText(associado.getIdendereco().getCep());
//        bairrojTextField2.setText(associado.getIdendereco().getBairro());
   //     cidadejTextField2.setText(associado.getIdendereco().getCidade());
    //    estadojComboBox3.setSelectedItem(associado.getIdendereco().getEstado());
        residencialjFormattedTextField3.setText(associado.getFoneResidencial());
        celularljFormattedTextField4.setText(associado.getFoneCelular());
        recadoljFormattedTextField1.setText(associado.getFoneRecado());
        emailjTextField2.setText(associado.getEmail());
        nCPFjFormattedTextField1.setText(associado.getCpf());
        nRGjTextField2.setText(associado.getRg());
//        orgaoEmissorjFormattedTextField2.setText(associado.getIdorgaoemissor().getNome());
        dtNascjFormattedTextField1.setValue((Date)associado.getDataNasc());
        nomeMaejTextField2.setText(associado.getNomeMae());
        numBeneficiojTextField2.setText(associado.getNumBeneficio());
        vlBeneficiojFormattedTextField1.setValue(associado.getValor());
        percentualjFormattedTextField1.setValue(associado.getPercDesconto());
        nomeResponsaveljTextField2.setText(associado.getResponsavel());
        nomeAgentePagadorjTextField2.setText(associado.getAgentePagador());
        mesCompetenciajFormattedTextField1.setText(associado.getMesCompetencia());
      
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel AssociadosjPanel;
    private javax.swing.JFormattedTextField CEPjFormattedTextField1;
    private javax.swing.JLabel CelularjLabel15;
    private javax.swing.JButton IncluirjButton;
    private javax.swing.JButton LimparjButton;
    private javax.swing.JPanel SexojPanel2;
    private javax.swing.JTextField bairrojTextField2;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JFormattedTextField celularljFormattedTextField4;
    private javax.swing.JTextField cidadejTextField2;
    private javax.swing.JTextField complementojTextField2;
    private javax.swing.JFormattedTextField dtNascjFormattedTextField1;
    private javax.swing.JTextField emailjTextField2;
    private javax.swing.JComboBox estadojComboBox3;
    private javax.swing.JRadioButton femininojRadioButton1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JPopupMenu jPopupMenu2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTextField logradourojTextField2;
    private javax.swing.JRadioButton masculinojRadioButton2;
    private javax.swing.JFormattedTextField mesCompetenciajFormattedTextField1;
    private javax.swing.JFormattedTextField nCPFjFormattedTextField1;
    private javax.swing.JTextField nRGjTextField2;
    private javax.swing.JTextField nomeAgentePagadorjTextField2;
    private javax.swing.JTextField nomeMaejTextField2;
    private javax.swing.JTextField nomeResponsaveljTextField2;
    private javax.swing.JTextField nomejTextField1;
    private javax.swing.JTextField numAgenciajTextField2;
    private javax.swing.JTextField numBeneficiojTextField2;
    private javax.swing.JTextField numjTextField3;
    private javax.swing.JFormattedTextField orgaoEmissorjFormattedTextField2;
    private javax.swing.JFormattedTextField percentualjFormattedTextField1;
    private javax.swing.JFormattedTextField recadoljFormattedTextField1;
    private javax.swing.JFormattedTextField residencialjFormattedTextField3;
    private javax.swing.JComboBox situacaojComboBox2;
    private javax.swing.JComboBox tipojComboBox1;
    private javax.swing.JComboBox tipologradourojComboBox1;
    private javax.swing.JFormattedTextField vlBeneficiojFormattedTextField1;
    // End of variables declaration//GEN-END:variables
    private Associado associado;
    private AssociadoDAO dao;
}
